package com.fs.base.pojo;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.annotations.GenericGenerator;

import com.alibaba.fastjson.annotation.JSONField;
import com.fs.base.annotation.ColumnDesc;
import com.fs.base.param.SysConstant;

/**
 * @author TiddlerCJ
 * 标注为@MappedSuperclass的类将不是一个完整的实体类，他将不会映射到数据库表，但是他的属性都将映射到其子类的数据库字段中。
 * 标注为@MappedSuperclass的类不能再标注@Entity或@Table注解，也无需实现序列化接口
 */
@MappedSuperclass
public class PkEntity{
	/**
	 * 主键策略
	*/
	@Id @Setter@Getter
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid")
	@Column(name="id", columnDefinition="varchar(48) COMMENT '主键'")
	@ColumnDesc(name="主键") 
	public String id;
	
	/**
	 * 默认创建时间，子段名称:create_time
	*/
	
	@JSONField (format="yyyy-MM-dd HH:mm:ss")
	@Column(name="create_time", nullable = true, columnDefinition = "datetime  COMMENT '创建时间'")
	@Setter@Getter
	@ColumnDesc(name="创建时间")
	private Date createTime = new Date();
	
	@ColumnDesc(name="创建人ID")
	@Setter@Getter
	@Column(name="creater_id", columnDefinition = "varchar(48) COMMENT '创建人ID'")
	public String createrId;
	
	@Transient
	private String  createrName;
	public String getCreaterName(){
		return SysConstant.USERS_ID_NAME_MAP.get(this.getCreaterId());
	}
	
	@Setter@Getter
	@ColumnDesc(name="组织编码") 
	private String orgNo;
	
	
	@Transient
	private String  orgNoName;
	public String getOrgNoName(){
		return SysConstant.ORG_NO_NAME_MAP.get(this.getOrgNo());
	}
	
	
	/**
	 * 数据库主键字段名称
	 */
	@Transient
	public final static String PRIMARY_KEY_NAME = "id";
}
